package com.me.Design;

import com.me.dao.builder.SingletonPattern.*;

/**
 * 功能：单例模式测试(Singleton Pattern)
 *
 * @author：dongshibo(F_baisi)
 * @create：2019/1/25/025 10:39
 * @version：2019 Version：1.0
 * @company：老屋新房 Created with IntelliJ IDEA
 */
public class SingletonDesignTest {

	public static void main(String[] args) {
		//无参构造器私有化因此new对象时报错
		//ZhPeopleModelBuilde zhPeopleModelBuilde = new ZhPeopleModelBuilde();
		//饿汉式
		ZhPeopleModelBuilde zhPeopleModelBuilde = ZhPeopleModelBuilde.GetZhPeople();
		zhPeopleModelBuilde.show();

//		//证明单例是否成功
//		ZhPeopleModelBuilde zhPeopleModelBuilde1 = ZhPeopleModelBuilde.GetZhPeople();
//		System.out.println(zhPeopleModelBuilde==zhPeopleModelBuilde1);
//
//		//协助证明单例
//		DbPeopleModelBuilder dbPeopleModelBuilder = new DbPeopleModelBuilder();
//		DbPeopleModelBuilder dbPeopleModelBuilder1= new DbPeopleModelBuilder();
//		System.out.println(dbPeopleModelBuilder==dbPeopleModelBuilder1);
		//懒汉式，线程不安全
		ZzPeopleModelBuilder zzPeople = ZzPeopleModelBuilder.getZzPeople();
		zzPeople.show();
//		//证明单例
//		System.out.println(zzPeople==ZzPeopleModelBuilder.getZzPeople());;
		//懒汉式，线程安全
		LtPeopleModelBuilder ltPeople = LtPeopleModelBuilder.getLtPeople();
		ltPeople.show();
//		//证明单例
//		System.out.println(ltPeople==LtPeopleModelBuilder.getLtPeople());
		//双检锁/双重校验锁
		LzyPeopleModelBuilder lzyPeopleModelBuilder = LzyPeopleModelBuilder.getLzyPeopleModelBuilder();
		lzyPeopleModelBuilder.show();
		//登记式/静态内部类
		XzhPeopleModelBuilder.getPeople().show();
		//枚举
		LhPeopleModelBuilder.GETPEOPLE.getLhPeopleModelBuilder();
	}
}
